clear all

cd "/Users/sambuehl/Dropbox/ForTheyKnowNot/ForTheyKnowNot/REPLICATION PACKAGE/"
 
 
set more off

use "data/data.dta", replace

******* Data householding *******
if 1 {
	su iq
	local mean = r(mean)
	local sd = r(sd)
	capture gen iqNorm = 15 * (iq - `mean')/`sd' + 100

	
	egen iqR = rank(iq) 
	count 
	local numSub = r(N)
	replace iqR = iqR / `numSub'
	
	egen iqRankUninc = rank(iq) if session <= 10 
	count if session <= 10 
	local numUninc = r(N)
	replace iqRankUninc = iqRankUninc / `numUninc'
	
	egen iqRankInc = rank(iq) if session > 10 & session <= 17
	count if session > 10 & session <= 17
	local numInc = r(N)
	replace iqRankInc = iqRankInc / `numInc'
	

	gen resPrice = (resPrice1 + resPrice2 + resPrice3 + resPrice4) / 4

	forvalues i = 1 / 4 {
		egen wtaRank`i' = rank(resPrice`i')
		replace wtaRank`i' = wtaRank`i' / _N
	}

	egen wtaRankMean = rank(resPrice)
	replace wtaRankMean = wtaRankMean / _N	

	bysort id: egen medTpic = median(tpicQ) if explicit == 0
	su medTpic, d
	gen shortTime = medTpic < r(p25)
	gen medTime = medTpic < r(p50)	
	
	replace abischnitt = . if abischnitt > 4
	replace abimath = . if abimath > 15
	replace abideutsch = . if abideutsch > 15

	drop lm*wta*
	
	gen emailGiven = email ~= ""
	
	// Risk aversion measures
	capture drop ceMean
	gen ceMean = ce1 + ce2 + ce3 + ce4 + ce5 + ce6 + ce7 + ce8 + ce9
	sort ceMean
	egen ceRank_i = rank(ceMean) if tagId == 1
	bysort id: egen ceRank = mean(ceRank_i)
	su ceRank
	replace ceRank = ceRank / r(max)
	drop ceRank_i
	count if tagId == 1
	local N = r(N)
	capture drop riskAversionIndex
	gen riskAversionIndex_i = 1 - (ceRank / `N')
	bysort id: egen riskAversionIndex = max(riskAversionIndex_i)
	capture drop ceOdd ceEven
	gen ceOdd = ce1 + ce3 + ce5 + ce7 + ce9
	gen ceEven = ce2 + ce4 + ce6 + ce8
	
	gen resPriceOdd = resPrice1 + resPrice3
	gen resPriceEven = resPrice2 + resPrice4
	

	capture drop iqEven iqOdd iqPred*
	gen iqEven = iq2+iq4+iq6+iq8+iq10+iq12+iq14+iq16+iq18+iq20+iq22+iq24+iq26+iq28+iq30+iq32+iq34+iq36
	gen iqOdd = iq1+iq3+iq5+iq7+iq9+iq11+iq13+iq15+iq17+iq19+iq21+iq23+iq25+iq27+iq29+iq31+iq33+iq35
	
	
	
	su incentive

	if r(min) == -1 {
		replace incentive = 2/12 if incentive == -1
		replace incentive = 6/12 if incentive == 0
		replace incentive = 10/12 if incentive == 1
	}


	foreach var in monthlyexpenses ownearnings allowance parentwealth {
		capture gen log`var' = log(`var')
	}
	
	capture drop moneyPCA
	pca logmonthlyexpenses logownearnings logallowance logparentwealth
	predict moneyPCA, sc
	// note: stata centers and scales the PCA inputs automatically
	
	capture drop minLogTiq
	gen minLogTiq = min(logTiq1, logTiq2, logTiq3, logTiq4, logTiq5, logTiq6)
		
	gen sessionTime = .
	replace sessionTime = 1 if session == 1
	replace sessionTime = 1 if session == 2
	replace sessionTime = 2 if session == 3
	replace sessionTime = 3 if session == 4
	replace sessionTime = 1 if session == 5
	replace sessionTime = 2 if session == 6
	replace sessionTime = 1 if session == 7
	replace sessionTime = 2 if session == 8
	replace sessionTime = 1 if session == 9
	replace sessionTime = 2 if session == 10
	replace sessionTime = 2 if session == 11	
	replace sessionTime = 1 if session == 12
	replace sessionTime = 2 if session == 13
	replace sessionTime = 1 if session == 14
	replace sessionTime = 2 if session == 15
	replace sessionTime = 1 if session == 16
	replace sessionTime = 2 if session == 17
	replace sessionTime = 1 if session == 18
	replace sessionTime = 2 if session == 19
	
	gen sessionWeekday = . // 1 = Monday, 2 = Tuesday, ...
	replace sessionWeekday = 4 if session == 1
	replace sessionWeekday = 3 if session == 2
	replace sessionWeekday = 3 if session == 3
	replace sessionWeekday = 3 if session == 4
	replace sessionWeekday = 3 if session == 5
	replace sessionWeekday = 3 if session == 6
	replace sessionWeekday = 4 if session == 7
	replace sessionWeekday = 4 if session == 8
	replace sessionWeekday = 5 if session == 9
	replace sessionWeekday = 5 if session == 10
	replace sessionWeekday = 5 if session == 11
	replace sessionWeekday = 1 if session == 12
	replace sessionWeekday = 1 if session == 13
	replace sessionWeekday = 1 if session == 14
	replace sessionWeekday = 1 if session == 15
	replace sessionWeekday = 2 if session == 16
	replace sessionWeekday = 2 if session == 17
	replace sessionWeekday = 1 if session == 18
	replace sessionWeekday = 1 if session == 19
	
	gen friday = sessionWeekday == 5
	
	
	gen riskPremium = 0
	forvalues i = 1 / 9 {
		gen riskPremium`i' = ce`i' - ceRiskNeut`i'
		replace riskPremium = riskPremium + riskPremium`i'/9
	}
	gen riskAverse = riskPremium < 0
	
	gen thresCost = cost
		
	su thresCost 
	local minThresCost = r(min)
	replace thresCost = thresCost / `minThresCost'

	replace cost = 0 if explicit == 1
	replace thresCost = 0 if explicit == 1
	
	gen inc_thresCost = incentive * thresCost
	gen inc_explGood = incentive * explicitGood
	gen inc_explBad = incentive * explicitBad
	gen inc_explicit = incentive * explicit
	
	gen inc_wtaRankMean = incentive * wtaRankMean
	gen thresCost_wtaRankMean = thresCost * wtaRankMean
	gen thresCost_inc_wtaRankMean = thresCost * inc_wtaRankMean
	
	gen inc_iqRankUninc = incentive * iqRankUninc
	gen thresCost_iqRankUninc = thresCost * iqRankUninc
	gen thresCost_inc_iqRankUninc = thresCost * inc_iqRankUninc

	gen inc_iqRankInc = incentive * iqRankInc
	gen thresCost_iqRankInc = thresCost * iqRankInc
	gen thresCost_inc_iqRankInc = thresCost * inc_iqRankInc	
	
	drop incentives 	// this is some variable that was used in the javascript code of the survey
	
	
	
	capture drop responsiveness*
	gen responsivenessPos_i = (plik - 0.5) / (bayesPost - 0.5) if explicit == 1 & bayesPost > 0.5
	bysort id: egen responsivenessPos = mean(responsivenessPos_i)
	gen responsivenessNeg_i = (plik - 0.5) / (bayesPost - 0.5) if explicit == 1 & bayesPost < 0.5
	bysort id: egen responsivenessNeg = mean(responsivenessNeg_i)
	
	gen responsiveness_i = .
	replace responsiveness_i = responsivenessPos_i if bayesPost > 0.5 
	replace responsiveness_i = responsivenessNeg_i if bayesPost < 0.5 
	bysort id: egen responsiveness = mean(responsiveness_i)

	
	egen abimathRank = rank(abimath)  
	count if abimathRank ~= .
	local num = r(N)
	replace abimathRank = abimathRank / `num'
	

	egen abideutschRank = rank(abideutsch)  
	count if abideutschRank ~= .
	local num = r(N)
	replace abideutschRank = abideutschRank / `num'
	

	egen abiRank = rank(abischnitt)  
	count if abiRank ~= .
	local num = r(N)
	replace abiRank = abiRank / `num'
	
	gen STEM = major == 1 | major == 5
	
	bysort id: egen minTpic = min(tpicQ) if explicit == 0
	
	gen ceRank_inc = incentive * ceRank
	gen ceRank_cost_inc = incentive * ceRank * thresCost
	gen ceRank_cost = ceRank * thresCost
	
	gen inc_ceRank = ceRank_inc
	
	gen inc0 = incentive == 0
	gen inc1 = incentive == 1
	gen inc2 = incentive == 2

	gen inc0_cost = inc0 * (thresCost - 1)
	gen inc1_cost = inc1 * (thresCost - 1)
	gen inc2_cost = inc2 * (thresCost - 1)	

	gen inc0_ceRank = inc0 * ceRank 
	gen inc1_ceRank = inc1 * ceRank 
	gen inc2_ceRank = inc2 * ceRank 	

	gen inc0_explicit = inc0 * explicit
	gen inc1_explicit = inc1 * explicit
	gen inc2_explicit = inc2 * explicit	
	
	gen inc0a = inc0 
	gen inc1a = inc1 
	gen inc2a = inc2 
	
	gen devPost = plik - state
	
	// Variables for demand curve estimations	

	su minTpic, d
	local medMinT = r(p50)
	cap gen intensiveMargin = minTpic >= `medMinT'

	cap  gen weightIntensive = .
	su treatment
	local numTreatments = r(max)
	forvalues t = 1 / `numTreatments' {
		su state if treatment == `t' & intensiveMargin == 1
		replace weightIntensive = 1 / r(mean)				if state == 1 & treatment == `t' & intensiveMargin == 1
		replace weightIntensive = 1 / (1 - r(mean)) 		if state == 0 & treatment == `t' & intensiveMargin == 1
	}
	
	su resPrice, d
	cap gen binResPrice = resPrice >= r(p50)
	cap gen inc_binResPrice = incentive * binResPrice
	
	cap gen flexInfo = 1 - explicit
	cap gen inc_flexInfo = incentive * flexInfo
	cap gen flexInfo_binResPrice = flexInfo * binResPrice
	cap gen inc_flexInfo_binResPrice = incentive * flexInfo * binResPrice
	
	
	
	
	cap gen cost_resPrice = cost * binResPrice
	cap gen cost_inc_resPrice = incentive * cost_resPrice
	
	cap gen cost_incentive = cost * incentive
	
	cap gen ceRank_cost						 = ceRank * cost
	cap gen ceRank_cost_inc					 = ceRank * cost * incentive
	cap gen ceRank_inc_cost					 = ceRank * cost * incentive
	cap gen ceRank_inc 						 = incentive * ceRank
	cap gen ceRank_binResPrice				 = ceRank * binResPrice
	cap gen inc_ceRank_binResPrice			 = incentive * ceRank * binResPrice
	cap gen cost_ceRank_binResPrice			 = cost * ceRank * binResPrice
	cap gen cost_inc_ceRank_binResPrice		 = cost * incentive * ceRank * binResPrice
	
	cap gen cost_flexInfo 					= cost * flexInfo
	cap gen cost_inc_flexInfo 				= cost * incentive * flexInfo
	cap gen cost_flexInfo_binResPrice 		= cost * flexInfo * binResPrice
	cap gen cost_inc_flexInfo_binResPrice	= cost * incentive * flexInfo * binResPrice
	
	
	// Variables for selection on risk preferences
	if 1 {
	
		cap drop ceNeg
		gen ceNeg = ce1 + ce4 + ce5 // + ce6
		cap drop ceNegNorm
		su ceNeg
		egen ceNegRank = group(ceNeg)
		su ceNegRank
		replace ceNegRank = ceNegRank / r(max)
		
		cap drop cePos
		gen cePos = ce2 + ce3 + ce6 + ce7 + ce8 + ce9
		cap drop cePosRank
		egen cePosRank = group(cePos)
		su cePosRank
		replace cePosRank = cePosRank / r(max)
			
		cap drop ceEven 
		cap drop ceOdd
		gen ceEven = ce2 + ce4 + ce6 + ce8	
		gen ceOdd = ce1 + ce3 + ce5 + ce7 + ce9	
		

		// individual regressions
		
		cap drop mathBackground
		pca abimathRank STEM matheLK
		predict mathBackground, score
		su mathBackground
		replace mathBackground = (mathBackground - r(min))/(r(max) - r(min))

		cap drop deutschBackground
		pca abideutschRank deutschLK
		predict deutschBackground, score
		su deutschBackground
		replace deutschBackground = (deutschBackground - r(min))/(r(max) - r(min))
		
		
		
		
		gen ce5050 = ce1 + ce4 + ce7
		gen ceNon5050 = ce2 + ce3 + ce5 + ce6 + ce8 + ce9
		gen ce7525 = ce2 + ce5 + ce8
		gen ceNon7525 = ce1 + ce3 + ce4 + ce6 + ce7 + ce9
		gen ce9010 = ce3 + ce6 + ce9
		gen ceNon9010 = ce1 + ce2 + ce4 + ce5 + ce7 + ce8
		
		gen ce66 = ce1 + ce2 + ce3
		gen ceNon66 = ce4 + ce5 + ce6 + ce7 + ce8 + ce9
		gen ce210 = ce4 + ce5 + ce6
		gen ceNon210 = ce1 + ce2 + ce3 + ce7 + ce8 + ce9
		gen ce102 = ce7 + ce8 + ce9
		gen ceNon102 = ce1 + ce2 + ce3 + ce4 + ce5 + ce6
		
		
		reg cePos 	ceNeg	
		reg ce5050 	ceNon5050
		reg ce7525 	ceNon7525
		reg ce9010 	ceNon9010
		reg ce66 	ceNon66
		reg ce210 	ceNon210
		reg ce102 	ceNon102  
		
		
		gen ce50incLow 	= ce4 >= 0
		gen ce50incMed 	= ce1 >= 0
		gen ce50incHigh = ce7 >= 0

		gen ce75incLow 	= ce5 >= 0
		gen ce75incMed 	= ce2 >= 0
		gen ce75incHigh = ce8 >= 0
		
		gen ce90incLow 	= ce6 >= 0
		gen ce90incMed 	= ce3 >= 0
		gen ce90incHigh = ce9 >= 0
		
			
		egen ce5050rank = rank(ce5050)
		su ce5050rank
		replace ce5050rank = ce5050rank / r(max)

		egen ceNon5050rank = rank(ceNon5050)
		su ceNon5050rank
		replace ceNon5050rank = ceNon5050rank / r(max)

		egen ceNon7525rank = rank(ceNon7525)
		su ceNon7525rank
		replace ceNon7525rank = ceNon7525rank / r(max)

		egen ce7525rank = rank(ce7525)
		su ce7525rank
		replace ce7525rank = ce7525rank / r(max)

		egen ceNon9010rank = rank(ceNon9010)
		su ceNon9010rank
		replace ceNon9010rank = ceNon9010rank / r(max)
		
		egen ce9010rank = rank(ce9010)
		su ce9010rank
		replace ce9010rank = ce9010rank / r(max)
		

		gen incCost0 = incentive * (thresCost == 0)
		gen incCostAll = incentive * (thresCost ~= 0)
		gen incCost1 = incentive * (thresCost == 1)
		gen incCost2 = incentive * (thresCost == 2)
		gen incCost3 = incentive * (thresCost == 3)
		
		gen priorBetLow = ce4 > 0
		gen priorBetMed = ce1 > 0
		gen priorBetHigh = ce7 > 0

		gen consistent = ce4 <= ce1 & ce1 <= ce7
		
		local condition1 = "incentive <= 0.51 & ((priorBetMed == 0 & priorBetLow  == 0) | (priorBetMed == 1 & priorBetLow  == 1))"
		local condition2 = "incentive >= 0.49 & ((priorBetMed == 0 & priorBetHigh == 0) | (priorBetMed == 1 & priorBetHigh == 1))"
			
		gen priorSame = 0
		replace priorSame = 1 if `condition1' == 1
		replace priorSame = 2 if `condition2' == 1
				
		cap  gen weightRiskContLow = .
		su treatment
		local numTreatments = r(max)
		forvalues t = 1 / `numTreatments' {
			su state if treatment == `t' & `condition1' == 1
			replace weightRiskContLow = 1 / r(mean)			if state == 1 & treatment == `t' & `condition1' == 1
			replace weightRiskContLow = 1 / (1 - r(mean)) 	if state == 0 & treatment == `t' & `condition1' == 1
		}
		
		
		cap  gen weightRiskContHigh = .
		su treatment
		local numTreatments = r(max)
		forvalues t = 1 / `numTreatments' {
			su state if treatment == `t' & `condition2' == 1
			replace weightRiskContHigh = 1 / r(mean)		if state == 1 & treatment == `t' & `condition2' == 1
			replace weightRiskContHigh = 1 / (1 - r(mean)) 	if state == 0 & treatment == `t' & `condition2' == 1
		}
		
		gen weightRiskCont = .
		replace weightRiskCont = weightRiskContLow 	if `condition1' == 1
		replace weightRiskCont = weightRiskContHigh if `condition2' == 1
			
		
	}
		
	
	cap gen noBet 			= 1 - bet
	cap gen inc_bet 		= incentive*bet
	cap gen inc_noBet 		= incentive*(1-bet)
	cap gen cost_bet 		= thresCost*bet
	cap gen cost_noBet 		= thresCost*(1-bet)
	cap gen costInc_bet		= thresCost*incentive*bet
	cap gen costInc_noBet	= thresCost*incentive*(1-bet)

	cap gen inc_bet_endo 	= inc_bet*(1 - explicit)
	cap gen inc_noBet_endo 	= inc_noBet*(1 - explicit)
	cap gen inc_bet_exo 	= inc_bet*explicit
	cap gen inc_noBet_exo 	= inc_noBet*explicit
	cap gen endo 			= 1 - explicit

	
}


// Reported in main text
if 1 {
	noisily: su age male if tag == 1
}

// TABLE 2 
if 1 {
	
		cap gen flexInfo 			= 1 - explicit
		cap gen inc_flexInfo 		= incentive * flexInfo
		cap gen cost_flexInfo 		= cost * flexInfo
		cap gen cost_inc_flexInfo 	= cost * incentive * flexInfo
		
		cap gen ceRank_cost			= ceRank * cost
		cap gen ceRank_inc_cost		= ceRank * cost * incentive
		cap gen ceRank_inc 			= incentive * ceRank
		
		
		reg thresCost inc_bet inc_noBet bet i.session i.order [aw = weight], cl(id)
		reg thresCost inc_bet inc_noBet bet i.session i.order [aw = weight] if bet == 1, cl(id)

		// Col 1 
		if 1 {
		local condition = "explicit == 0"
		reg thresCost [aw = weight] if `condition'
			local depVarMean = _b[_cons]
			local depVarSe = _se[_cons]
		reg thresCost inc_bet inc_noBet bet i.session i.order [aw = weight] ///
			if `condition' & incentive < 0.51, cl(id)
			local b1 = _b[inc_bet]
			local se1 = _se[inc_bet]
			test inc_bet == 0
			local p = r(p)
			local sig1 = "-"
			if `p' < 0.1 {
				local sig1 = "*"
			}
			if `p' < 0.05 {
				local sig1 = "**"
			}
			if `p' < 0.001 {
				local sig1 = "***"
			}
		reg thresCost inc_bet inc_noBet bet i.session i.order [aw = weight] ///
			if `condition' & incentive > 0.49, cl(id)
			local b2 = _b[inc_bet]
			local se2 = _se[inc_bet]
			test inc_bet == 0
			local p = r(p)
			local sig2 = "-"
			if `p' < 0.1 {
				local sig2 = "*"
			}
			if `p' < 0.05 {
				local sig2 = "**"
			}
			if `p' < 0.001 {
				local sig2 = "***"
			}
		reg thresCost inc_bet inc_noBet bet i.session i.order [aw = weight] ///
			if `condition' & cost <= 2, cl(id)
			local b3 = _b[inc_bet]
			local se3 = _se[inc_bet]
			test inc_bet == 0
			local p = r(p)
			local sig3 = "-"
			if `p' < 0.1 {
				local sig3 = "*"
			}
			if `p' < 0.05 {
				local sig3 = "**"
			}
			if `p' < 0.001 {
				local sig3 = "***"
			}
		reg thresCost inc_bet inc_noBet bet i.session i.order [aw = weight] ///
			if `condition' & cost >= 2, cl(id)
			local b4 = _b[inc_bet]
			local se4 = _se[inc_bet]
			test inc_bet == 0
			local p = r(p)
			local sig4 = "-"
			if `p' < 0.1 {
				local sig4 = "*"
			}
			if `p' < 0.05 {
				local sig4 = "**"
			}
			if `p' < 0.001 {
				local sig4 = "***"
			}
		
		reg thresCost inc_bet inc_noBet noBet i.session i.order [aw = weight] ///
			if `condition', cl(id)
			local numSubj = e(N_clust)
			outreg2 using "tables/tableCombined.tex",  ///
			keep(inc_bet inc_noBet noBet) dec(3)  ///
			adec(3) ///
			addstat("#Subj", `numSubj', "b1", `b1', "se1", `se1', "b2", `b2', "se2", `se2', "b3", `b3', "se3", `se3', "b4", `b4', "se4", `se4', "DepVar mean", `depVarMean', "DepVar SE", `depVarSe') /// 
			addtext("Obs included", "All", "sig1", `sig1', "sig2", `sig2', "sig3", `sig3', "sig4", `sig4') ///
			tex(frag) replace 
		}
		
		// Col 2 
		if 1 {
		local condition = "explicit == 0"
		local controls = " "
		reg wtaRankMean [aw = weight] if `condition'
			local depVarMean = _b[_cons]
			local depVarSe = _se[_cons]
		reg wtaRankMean inc_bet inc_noBet bet i.session i.order [aw = weight] ///
			if `condition' & incentive < 0.51, cl(id)
			local b1 = _b[inc_bet]
			local se1 = _se[inc_bet]
			test inc_bet == 0
			local p = r(p)
			local sig1 = "-"
			if `p' < 0.1 {
				local sig1 = "*"
			}
			if `p' < 0.05 {
				local sig1 = "**"
			}
			if `p' < 0.001 {
				local sig1 = "***"
			}
		reg wtaRankMean inc_bet inc_noBet bet i.session i.order [aw = weight] ///
			if `condition' & incentive > 0.49, cl(id)
			local b2 = _b[inc_bet]
			local se2 = _se[inc_bet]
			test inc_bet == 0
			local p = r(p)
			local sig2 = "-"
			if `p' < 0.1 {
				local sig2 = "*"
			}
			if `p' < 0.05 {
				local sig2 = "**"
			}
			if `p' < 0.001 {
				local sig2 = "***"
			}
		reg wtaRankMean inc_bet inc_noBet bet i.session i.order [aw = weight] ///
			if `condition' & cost <= 2, cl(id)
			local b3 = _b[inc_bet]
			local se3 = _se[inc_bet]
			test inc_bet == 0
			local p = r(p)
			local sig3 = "-"
			if `p' < 0.1 {
				local sig3 = "*"
			}
			if `p' < 0.05 {
				local sig3 = "**"
			}
			if `p' < 0.001 {
				local sig3 = "***"
			}
		reg wtaRankMean inc_bet inc_noBet bet i.session i.order [aw = weight] ///
			if `condition' & cost >= 2, cl(id)
			local b4 = _b[inc_bet]
			local se4 = _se[inc_bet]
			test inc_bet == 0
			local p = r(p)
			local sig4 = "-"
			if `p' < 0.1 {
				local sig4 = "*"
			}
			if `p' < 0.05 {
				local sig4 = "**"
			}
			if `p' < 0.001 {
				local sig4 = "***"
			}
		reg wtaRankMean inc_bet inc_noBet noBet `controls' i.session i.order [aw = weight] ///
			if `condition', cl(id)
			local numSubj = e(N_clust)
			outreg2 using "tables/tableCombined.tex",  ///
			keep(inc_bet inc_noBet noBet) dec(3)  ///
			adec(3) ///
			addstat("#Subj", `numSubj', "b1", `b1', "se1", `se1', "b2", `b2', "se2", `se2', "b3", `b3', "se3", `se3', "b4", `b4', "se4", `se4', "DepVar mean", `depVarMean', "DepVar SE", `depVarSe') /// 
			addtext("Obs included", "All", "sig1", `sig1', "sig2", `sig2', "sig3", `sig3', "sig4", `sig4') ///
			tex(frag)  

		}
			
		// Col 3 
		if 1 {
		local condition = "explicit == 1"
		local controls = " "
		reg wtaRankMean [aw = weight] if `condition'
			local depVarMean = _b[_cons]
			local depVarSe = _se[_cons]
		reg wtaRankMean inc_bet inc_noBet bet i.session i.order [aw = weight] ///
			if `condition' & incentive < 0.51, cl(id)
			local b1 = _b[inc_bet]
			local se1 = _se[inc_bet]
			test inc_bet == 0
			local p = r(p)
			local sig1 = "-"
			if `p' < 0.1 {
				local sig1 = "*"
			}
			if `p' < 0.05 {
				local sig1 = "**"
			}
			if `p' < 0.001 {
				local sig1 = "***"
			}
		reg wtaRankMean inc_bet inc_noBet bet i.session i.order [aw = weight] ///
			if `condition' & incentive > 0.49, cl(id)
			local b2 = _b[inc_bet]
			local se2 = _se[inc_bet]
			test inc_bet == 0
			local p = r(p)
			local sig2 = "-"
			if `p' < 0.1 {
				local sig2 = "*"
			}
			if `p' < 0.05 {
				local sig2 = "**"
			}
			if `p' < 0.001 {
				local sig2 = "***"
			}
			local b3 = 0
			local se3 = 0
			local sig3 = "-"
			local b4 = 0
			local se4 = 0
			local sig4 = "-"
			
		reg wtaRankMean inc_bet inc_noBet noBet `controls' i.session i.order [aw = weight] ///
			if `condition', cl(id)
			local numSubj = e(N_clust)
			outreg2 using "tables/tableCombined.tex",  ///
			keep(inc_bet inc_noBet noBet) dec(3)  ///
			adec(3) ///
			addstat("#Subj", `numSubj', "b1", `b1', "se1", `se1', "b2", `b2', "se2", `se2', "b3", `b3', "se3", `se3', "b4", `b4', "se4", `se4', "DepVar mean", `depVarMean', "DepVar SE", `depVarSe') /// 
			addtext("Obs included", "All", "sig1", `sig1', "sig2", `sig2', "sig3", `sig3', "sig4", `sig4') ///
			tex(frag)
			
			// Test for difference in selection effect fixed info vs. endogenous info
			if 1 {
				cap gen incExplicit = incentive * explicit
				local condition = "1"
				reg wtaRankMean incentive incExplicit i.cost  i.session i.order [aw = weight] ///
					if `condition' & bet == 1, cl(id)
				reg wtaRankMean incentive incExplicit i.cost [aw = weight] ///
					if `condition' & bet == 1, cl(id)
					
				local condition = "incentive < 0.51"
				xi: reg wtaRankMean incentive incExplicit i.cost i.session i.order [aw = weight] ///
					if `condition' & bet == 1, cl(id)
				local condition = "incentive > 0.49"
				xi: reg wtaRankMean incentive incExplicit i.cost i.session i.order [aw = weight] ///
					if `condition' & bet == 1, cl(id)
				local condition = "cost <= 2"
				xi: reg wtaRankMean incentive incExplicit i.cost i.session i.order [aw = weight] ///
					if `condition' & bet == 1, cl(id)
				local condition = "cost >= 2 | cost == 0"
				xi: reg wtaRankMean incentive incExplicit i.cost i.session i.order [aw = weight] ///
					if `condition' & bet == 1, cl(id)
					
					
					
				// Say that the session and round fixed effects suck up power, so the difference is not statistically significant. 
			}
		}
		
		// Col 4 
		if 1 {
		local condition = "explicit == 0"
		reg wtaRankMean [aw = weight] if `condition'
			local depVarMean = _b[_cons]
			local depVarSe = _se[_cons]
		reg wtaRankMean inc_bet cost_bet costInc_bet bet inc_noBet cost_noBet costInc_noBet i.session i.order [aw = weight] ///
			if `condition' & incentive < 0.51, cl(id)
			local b1 = _b[costInc_bet]
			local se1 = _se[costInc_bet]
			test costInc_bet == 0
			local p = r(p)
			local sig1 = "-"
			if `p' < 0.1 {
				local sig1 = "*"
			}
			if `p' < 0.05 {
				local sig1 = "**"
			}
			if `p' < 0.001 {
				local sig1 = "***"
			}
		reg wtaRankMean inc_bet cost_bet costInc_bet bet inc_noBet cost_noBet costInc_noBet i.session i.order [aw = weight] ///
			if `condition' & incentive > 0.49, cl(id)
			local b2 = _b[costInc_bet]
			local se2 = _se[costInc_bet]
			test costInc_bet == 0
			local p = r(p)
			local sig2 = "-"
			if `p' < 0.1 {
				local sig2 = "*"
			}
			if `p' < 0.05 {
				local sig2 = "**"
			}
			if `p' < 0.001 {
				local sig2 = "***"
			}
		reg wtaRankMean inc_bet cost_bet costInc_bet bet inc_noBet cost_noBet costInc_noBet i.session i.order [aw = weight] ///
			if `condition' & cost <= 2, cl(id)
			local b3 = _b[costInc_bet]
			local se3 = _se[costInc_bet]
			test costInc_bet == 0
			local p = r(p)
			local sig3 = "-"
			if `p' < 0.1 {
				local sig3 = "*"
			}
			if `p' < 0.05 {
				local sig3 = "**"
			}
			if `p' < 0.001 {
				local sig3 = "***"
			}
		reg wtaRankMean inc_bet cost_bet costInc_bet bet inc_noBet cost_noBet costInc_noBet i.session i.order [aw = weight] ///
			if `condition' & cost >= 2, cl(id)
			local b4 = _b[costInc_bet]
			local se4 = _se[costInc_bet]
			test costInc_bet == 0
			local p = r(p)
			local sig4 = "-"
			if `p' < 0.1 {
				local sig4 = "*"
			}
			if `p' < 0.05 {
				local sig4 = "**"
			}
			if `p' < 0.001 {
				local sig4 = "***"
			}

		reg wtaRankMean inc_bet cost_bet costInc_bet noBet inc_noBet cost_noBet costInc_noBet  i.session i.order [aw = weight] ///
			if `condition', cl(id)
			local numSubj = e(N_clust)
			outreg2 using "tables/tableCombined.tex",  ///
			keep(inc_bet cost_bet costInc_bet noBet inc_noBet cost_noBet costInc_noBet) dec(3)  ///
			adec(3) ///
			addstat("#Subj", `numSubj', "b1", `b1', "se1", `se1', "b2", `b2', "se2", `se2', "b3", `b3', "se3", `se3', "b4", `b4', "se4", `se4', "DepVar mean", `depVarMean', "DepVar SE", `depVarSe') /// 
			addtext("Obs included", "All", "sig1", `sig1', "sig2", `sig2', "sig3", `sig3', "sig4", `sig4') ///
			tex(frag)
		}	
		

		// Col 5 
		if 1 {
		local condition = "explicit == 0"
		reg bet [aw = weight] if `condition'
			local depVarMean = _b[_cons]
			local depVarSe = _se[_cons]
		reg bet incentive thresCost inc_thresCost i.session i.order [aw = weight] ///
			if `condition' & incentive < 0.51, cl(id)
			local b1 = _b[inc_thresCost]
			local se1 = _se[inc_thresCost]
			test inc_thresCost == 0
			local p = r(p)
			local sig1 = "-"
			if `p' < 0.1 {
				local sig1 = "*"
			}
			if `p' < 0.05 {
				local sig1 = "**"
			}
			if `p' < 0.001 {
				local sig1 = "***"
			}
		reg bet incentive thresCost inc_thresCost i.session i.order [aw = weight] ///
			if `condition' & incentive > 0.49, cl(id)
			local b2 = _b[inc_thresCost]
			local se2 = _se[inc_thresCost]
			test inc_thresCost == 0
			local p = r(p)
			local sig2 = "-"
			if `p' < 0.1 {
				local sig2 = "*"
			}
			if `p' < 0.05 {
				local sig2 = "**"
			}
			if `p' < 0.001 {
				local sig2 = "***"
			}
		reg bet incentive thresCost inc_thresCost i.session i.order [aw = weight] ///
			if `condition' & cost <= 2, cl(id)
			local b3 = _b[inc_thresCost]
			local se3 = _se[inc_thresCost]
			test inc_thresCost == 0
			local p = r(p)
			local sig3 = "-"
			if `p' < 0.1 {
				local sig3 = "*"
			}
			if `p' < 0.05 {
				local sig3 = "**"
			}
			if `p' < 0.001 {
				local sig3 = "***"
			}
		reg bet incentive thresCost inc_thresCost i.session i.order [aw = weight] ///
			if `condition' & cost >= 2, cl(id)
			local b4 = _b[inc_thresCost]
			local se4 = _se[inc_thresCost]
			test inc_thresCost == 0
			local p = r(p)
			local sig4 = "-"
			if `p' < 0.1 {
				local sig4 = "*"
			}
			if `p' < 0.05 {
				local sig4 = "**"
			}
			if `p' < 0.001 {
				local sig4 = "***"
			}
		reg bet incentive thresCost inc_thresCost i.session i.order [aw = weight] ///
			if `condition' , cl(id)
			local numSubj = e(N_clust)
			outreg2 using "tables/tableCombined.tex",  ///
			keep(incentive thresCost inc_thresCost ) dec(3)  ///
			adec(3) ///
			addstat("#Subj", `numSubj', "b1", `b1', "se1", `se1', "b2", `b2', "se2", `se2', "b3", `b3', "se3", `se3', "b4", `b4', "se4", `se4', "DepVar mean", `depVarMean', "DepVar SE", `depVarSe') /// 
			addtext("Obs included", "All", "sig1", `sig1', "sig2", `sig2', "sig3", `sig3', "sig4", `sig4') ///
			tex(frag)
		}	
		
		// Col 6 
		if 1 {
		local condition = "explicit == 0"				
		local control = " " 
		reg bet [aw = weight] if `condition'
			local depVarMean = _b[_cons]
			local depVarSe = _se[_cons]
		reg bet  incentive binResPrice inc_binResPrice i.session i.order [aw = weight] ///
			if `condition' & incentive < 0.51, cl(id)
			local b1 = _b[inc_binResPrice]
			local se1 = _se[inc_binResPrice]
			test inc_binResPrice == 0
			local p = r(p)
			local sig1 = "-"
			if `p' < 0.1 {
				local sig1 = "*"
			}
			if `p' < 0.05 {
				local sig1 = "**"
			}
			if `p' < 0.001 {
				local sig1 = "***"
			}
		reg bet  incentive binResPrice inc_binResPrice i.session i.order [aw = weight] ///
			if `condition' & incentive > 0.49, cl(id)
			local b2 = _b[inc_binResPrice]
			local se2 = _se[inc_binResPrice]
			test inc_binResPrice == 0
			local p = r(p)
			local sig2 = "-"
			if `p' < 0.1 {
				local sig2 = "*"
			}
			if `p' < 0.05 {
				local sig2 = "**"
			}
			if `p' < 0.001 {
				local sig2 = "***"
			}
		reg bet  incentive binResPrice inc_binResPrice i.session i.order [aw = weight] ///
			if `condition' & cost <= 2, cl(id)
			local b3 = _b[inc_binResPrice]
			local se3 = _se[inc_binResPrice]
			test inc_binResPrice == 0
			local p = r(p)
			local sig3 = "-"
			if `p' < 0.1 {
				local sig3 = "*"
			}
			if `p' < 0.05 {
				local sig3 = "**"
			}
			if `p' < 0.001 {
				local sig3 = "***"
			}
		reg bet incentive binResPrice inc_binResPrice i.session i.order [aw = weight] ///
			if `condition' & cost >= 2, cl(id)
			local b4 = _b[inc_binResPrice]
			local se4 = _se[inc_binResPrice]
			test inc_binResPrice == 0
			local p = r(p)
			local sig4 = "-"
			if `p' < 0.1 {
				local sig4 = "*"
			}
			if `p' < 0.05 {
				local sig4 = "**"
			}
			if `p' < 0.001 {
				local sig4 = "***"
			}
		xi: reg bet  incentive binResPrice inc_binResPrice `control' i.session i.order ///
			[aw = weight]	///
			if `condition' ///
			, cl(id)
			local numSubj = e(N_clust)
			outreg2 using "tables/tableCombined.tex",  ///
			keep(incentive binResPrice inc_binResPrice ) dec(3)  ///
			adec(3) ///
			addstat("#Subj", `numSubj', "b1", `b1', "se1", `se1', "b2", `b2', "se2", `se2', "b3", `b3', "se3", `se3', "b4", `b4', "se4", `se4', "DepVar mean", `depVarMean', "DepVar SE", `depVarSe') /// 
			addtext("Obs included", "All", "sig1", `sig1', "sig2", `sig2', "sig3", `sig3', "sig4", `sig4') ///
			tex(frag)
		}
		
		// Col 7 
		if 1 {
		local condition = "explicit == 1"				
		local control = " " 
		reg bet [aw = weight] if `condition'
			local depVarMean = _b[_cons]
			local depVarSe = _se[_cons]
		reg bet [aw = weight] if `condition'
			local depVarMean = _b[_cons]
			local depVarSe = _se[_cons]
		reg bet  incentive binResPrice inc_binResPrice i.session i.order [aw = weight] ///
			if `condition' & incentive < 0.51, cl(id)
			local b1 = _b[inc_binResPrice]
			local se1 = _se[inc_binResPrice]
			test inc_binResPrice == 0
			local p = r(p)
			local sig1 = "-"
			if `p' < 0.1 {
				local sig1 = "*"
			}
			if `p' < 0.05 {
				local sig1 = "**"
			}
			if `p' < 0.001 {
				local sig1 = "***"
			}
		reg bet  incentive binResPrice inc_binResPrice i.session i.order [aw = weight] ///
			if `condition' & incentive > 0.49, cl(id)
			local b2 = _b[inc_binResPrice]
			local se2 = _se[inc_binResPrice]
			test inc_binResPrice == 0
			local p = r(p)
			local sig2 = "-"
			if `p' < 0.1 {
				local sig2 = "*"
			}
			if `p' < 0.05 {
				local sig2 = "**"
			}
			if `p' < 0.001 {
				local sig2 = "***"
			}
			local b3 = 0
			local se3 = 0
			local sig3 = "-"
			local b4 = 0
			local se4 = 0
			local sig4 = "-"
		xi: reg bet  incentive binResPrice inc_binResPrice `control' i.session i.order ///
			[aw = weight]	///
			if `condition'  ///
			, cl(id)
			local numSubj = e(N_clust)
			outreg2 using "tables/tableCombined.tex",  ///
			keep(incentive binResPrice inc_binResPrice ) dec(3)  ///
			adec(3) ///
			addstat("#Subj", `numSubj', "b1", `b1', "se1", `se1', "b2", `b2', "se2", `se2', "b3", `b3', "se3", `se3', "b4", `b4', "se4", `se4', "DepVar mean", `depVarMean', "DepVar SE", `depVarSe') /// 
			addtext("Obs included", "All", "sig1", `sig1', "sig2", `sig2', "sig3", `sig3', "sig4", `sig4') ///
			tex(frag)
			
			// Test for difference in selection effect fixed info vs. endogenous info
			if 1 {
				cap gen incExplicit = incentive * explicit
				cap gen binResPriceExplicit = binResPrice * explicit
				cap gen incBinResPriceExplicit = inc_binResPrice * explicit
				local condition = "1"
				local controls = " "
				xi: reg bet  incentive binResPrice inc_binResPrice ///
					explicit incExplicit binResPriceExplicit incBinResPriceExplicit ///
					`control' i.session i.order ///
					[aw = weight]	///
					if `condition' ///
					, cl(id)
					test incBinResPriceExplicit = inc_binResPrice
			}
		}
			
		// Col 8 
		if 1 {
		local condition = "explicit == 0"				
		local control = "thresCost cost_incentive"	
		reg bet [aw = weight] if `condition'
			local depVarMean = _b[_cons]
			local depVarSe = _se[_cons]
		reg bet incentive binResPrice inc_binResPrice cost_resPrice cost_inc_resPrice i.session i.order [aw = weight] ///
			if `condition' & incentive < 0.51, cl(id)
			local b1 = _b[cost_inc_resPrice]
			local se1 = _se[cost_inc_resPrice]
			test cost_inc_resPrice == 0
			local p = r(p)
			local sig1 = "-"
			if `p' < 0.1 {
				local sig1 = "*"
			}
			if `p' < 0.05 {
				local sig1 = "**"
			}
			if `p' < 0.001 {
				local sig1 = "***"
			}
		reg bet incentive binResPrice inc_binResPrice cost_resPrice cost_inc_resPrice i.session i.order [aw = weight] ///
			if `condition' & incentive > 0.49, cl(id)
			local b2 = _b[cost_inc_resPrice]
			local se2 = _se[cost_inc_resPrice]
			test cost_inc_resPrice == 0
			local p = r(p)
			local sig2 = "-"
			if `p' < 0.1 {
				local sig2 = "*"
			}
			if `p' < 0.05 {
				local sig2 = "**"
			}
			if `p' < 0.001 {
				local sig2 = "***"
			}
		reg bet incentive binResPrice inc_binResPrice cost_resPrice cost_inc_resPrice i.session i.order [aw = weight] ///
			if `condition' & cost <= 2, cl(id)
			local b3 = _b[cost_inc_resPrice]
			local se3 = _se[cost_inc_resPrice]
			test cost_inc_resPrice == 0
			local p = r(p)
			local sig3 = "-"
			if `p' < 0.1 {
				local sig3 = "*"
			}
			if `p' < 0.05 {
				local sig3 = "**"
			}
			if `p' < 0.001 {
				local sig3 = "***"
			}
		reg bet incentive binResPrice inc_binResPrice cost_resPrice cost_inc_resPrice i.session i.order [aw = weight] ///
			if `condition' & cost >= 2, cl(id)
			local b4 = _b[cost_inc_resPrice]
			local se4 = _se[cost_inc_resPrice]
			test cost_inc_resPrice == 0
			local p = r(p)
			local sig4 = "-"
			if `p' < 0.1 {
				local sig4 = "*"
			}
			if `p' < 0.05 {
				local sig4 = "**"
			}
			if `p' < 0.001 {
				local sig4 = "***"
			}
		xi: reg bet incentive binResPrice inc_binResPrice cost_resPrice cost_inc_resPrice `control' i.session i.order ///
			[aw = weight]	///
			if `condition' ///
			, cl(id)
		local numSubj = e(N_clust)
		outreg2 using "tables/tableCombined.tex",  ///
			keep(incentive binResPrice inc_binResPrice cost_resPrice cost_inc_resPrice) dec(3)  ///
			adec(3) ///
			addstat("#Subj", `numSubj', "b1", `b1', "se1", `se1', "b2", `b2', "se2", `se2', "b3", `b3', "se3", `se3', "b4", `b4', "se4", `se4', "DepVar mean", `depVarMean', "DepVar SE", `depVarSe') /// 
			addtext("Obs included", "All", "sig1", `sig1', "sig2", `sig2', "sig3", `sig3', "sig4", `sig4') ///
			tex(frag)
		}	

}

// TABLE 3
if 1 {
	
	cap gen inc_bet 		= incentive*bet
	cap gen inc_noBet 		= incentive*(1-bet)
	cap gen cost_bet 		= thresCost*bet
	cap gen cost_noBet 		= thresCost*(1-bet)
	cap gen costInc_bet		= thresCost*incentive*bet
	cap gen costInc_noBet	= thresCost*incentive*(1-bet)
	cap gen wta_bet 		= wtaRankMean*bet
	cap gen wta_noBet 		= wtaRankMean*(1-bet)
	cap gen wtaInc_bet		= wtaRankMean*incentive*bet
	cap gen wtaInc_noBet	= wtaRankMean*incentive*(1-bet)

	cap gen inc_bet_endo 	= inc_bet*(1 - explicit)
	cap gen inc_noBet_endo 	= inc_noBet*(1 - explicit)
	cap gen inc_bet_exo 	= inc_bet*explicit
	cap gen inc_noBet_exo 	= inc_noBet*explicit
	cap gen endo 			= 1 - explicit

	// Induced cost variation
	
	reg state bet cost_bet inc_bet cost_noBet inc_noBet  i.session i.order ///
		if explicit == 0 [aw = weight], cl(id)
		local numSubj = e(N_clust)		
		outreg2 using "tables/posteriors.tex",  ///
			keep(cost_bet inc_bet cost_noBet inc_noBet) dec(3) adec(3)  ///
			addstat("#Subj", `numSubj') ///
			tex(frag) replace	

	// Measured cost variation
	
	reg state bet wta_bet inc_bet wta_noBet inc_noBet  i.session i.order ///
		if explicit == 0 [aw = weight], cl(id)
		local numSubj = e(N_clust)		
		outreg2 using "tables/posteriors.tex",  ///
			keep(wta_bet inc_bet wta_noBet inc_noBet) dec(3) adec(3)  ///
			addstat("#Subj", `numSubj') ///
			tex(frag) 
		
	// Subjective posteriors, induced 	
	
	reg plik bet cost_bet inc_bet cost_noBet inc_noBet  i.session i.order ///
		if explicit == 0 [aw = weight], cl(id)
		local numSubj = e(N_clust)		
		outreg2 using "tables/posteriors.tex",  ///
			keep(cost_bet inc_bet cost_noBet inc_noBet) dec(3) adec(3)  ///
			addstat("#Subj", `numSubj') ///
			tex(frag) 
			
		
	// Subjective posteriors, measured 	
	
	reg plik bet wta_bet inc_bet wta_noBet inc_noBet  i.session i.order ///
		if explicit == 0 [aw = weight], cl(id)
		local numSubj = e(N_clust)		
		outreg2 using "tables/posteriors.tex",  ///
			keep(wta_bet inc_bet wta_noBet inc_noBet) dec(3) adec(3)  ///
			addstat("#Subj", `numSubj') ///
			tex(frag) 
			
			
	// Diff subj obj, induced 
	
	reg devPost bet cost_bet inc_bet cost_noBet inc_noBet  i.session i.order ///
		if explicit == 0 [aw = weight], cl(id)
		local numSubj = e(N_clust)		
		outreg2 using "tables/posteriors.tex",  ///
			keep(cost_bet inc_bet cost_noBet inc_noBet) dec(3) adec(3)  ///
			addstat("#Subj", `numSubj') ///
			tex(frag) 
			
	// Diff subj obj, measured 
	
	reg devPost bet wta_bet inc_bet wta_noBet inc_noBet  i.session i.order ///
		if explicit == 0 [aw = weight], cl(id)
		local numSubj = e(N_clust)		
		outreg2 using "tables/posteriors.tex",  ///
			keep(wta_bet inc_bet wta_noBet inc_noBet) dec(3) adec(3)  ///
			addstat("#Subj", `numSubj') ///
			tex(frag) 
		
}

// TABLE 4
if 1 {
	// Panel A NEW: Selection 
	if 1 {

		local controls = "i.order i.session explicit"
		local contIndu = "i.order i.session "
		
		
		xi: reg abimathRank  [aw = weight] if explicit == 0, cl(id)
			local meanAll = _b[_cons]
			local seMeanAll = _se[_cons]
		xi: reg abimathRank  [aw = weight] if explicit == 0, cl(id)
			local meanSel = _b[_cons]
			local seMeanSel = _se[_cons]
		xi: reg abimathRank 	inc_bet inc_noBet bet 		`controls' [aw = weight] if explicit == 0, cl(id)
		local subj = e(N_clust)
		outreg2 using "tables/educSelection.tex",  ///
				drop(_I* o.*) dec(3) adec(3) ///
				addstat("subj", `subj', "Mean all", `meanAll', "SE mean all", `seMeanAll', "Mean participants", `meanSel', "SE mean participants", `seMeanSel') ///
				tex(frag) replace
		xi: reg matheLK  [aw = weight] if explicit == 0, cl(id)
			local meanAll = _b[_cons]
			local seMeanAll = _se[_cons]
		xi: reg matheLK  [aw = weight] if explicit == 0, cl(id)
			local meanSel = _b[_cons]
			local seMeanSel = _se[_cons]
		xi: reg matheLK inc_bet inc_noBet bet 	`controls' [aw = weight] if explicit == 0, cl(id)
		local subj = e(N_clust)
		outreg2 using "tables/educSelection.tex",  ///
				drop(_I* o.*) dec(3) adec(3) ///
				addstat("subj", `subj', "Mean all", `meanAll', "SE mean all", `seMeanAll', "Mean participants", `meanSel', "SE mean participants", `seMeanSel') ///
				tex(frag) 
		xi: reg STEM  [aw = weight] if explicit == 0, cl(id)
			local meanAll = _b[_cons]
			local seMeanAll = _se[_cons]
		xi: reg STEM  [aw = weight] if explicit == 0, cl(id)
			local meanSel = _b[_cons]
			local seMeanSel = _se[_cons]
		xi: reg STEM inc_bet inc_noBet bet 	`controls' [aw = weight] if explicit == 0, cl(id)
		local subj = e(N_clust)
		outreg2 using "tables/educSelection.tex",  ///
				drop(_I* o.*) dec(3) adec(3) ///
				addstat("subj", `subj', "Mean all", `meanAll', "SE mean all", `seMeanAll', "Mean participants", `meanSel', "SE mean participants", `seMeanSel') ///
				tex(frag) 
		xi: reg abideutschRank  [aw = weight] if explicit == 0, cl(id)
			local meanAll = _b[_cons]
			local seMeanAll = _se[_cons]
		xi: reg abideutschRank  [aw = weight] if explicit == 0, cl(id)
			local meanSel = _b[_cons]
			local seMeanSel = _se[_cons]
		xi: reg abideutschRank inc_bet inc_noBet bet 	`controls' [aw = weight] if explicit == 0, cl(id)
		local subj = e(N_clust)
		outreg2 using "tables/educSelection.tex",  ///
				drop(_I* o.*) dec(3) adec(3) ///
				addstat("subj", `subj', "Mean all", `meanAll', "SE mean all", `seMeanAll', "Mean participants", `meanSel', "SE mean participants", `seMeanSel') ///
				tex(frag) 
		xi: reg deutschLK  [aw = weight] if explicit == 0, cl(id)
			local meanAll = _b[_cons]
			local seMeanAll = _se[_cons]
		xi: reg deutschLK  [aw = weight] if explicit == 0, cl(id)
			local meanSel = _b[_cons]
			local seMeanSel = _se[_cons]
		xi: reg deutschLK inc_bet inc_noBet bet 	`controls' [aw = weight] if explicit == 0, cl(id)
		local subj = e(N_clust)
		outreg2 using "tables/educSelection.tex",  ///
				drop(_I* o.*) dec(3) adec(3) ///
				addstat("subj", `subj', "Mean all", `meanAll', "SE mean all", `seMeanAll', "Mean participants", `meanSel', "SE mean participants", `seMeanSel') ///
				tex(frag) 
				
		xi: reg iqRankU  [aw = weight] if explicit == 0, cl(id)
			local meanAll = _b[_cons]
			local seMeanAll = _se[_cons]
		xi: reg iqRankU  [aw = weight] if explicit == 0, cl(id)
			local meanSel = _b[_cons]
			local seMeanSel = _se[_cons]
		xi: reg iqRankU 		inc_bet inc_noBet bet tIq 	`controls' [aw = weight] if iqInc == 0 & explicit == 0, cl(id)
		local subj = e(N_clust)
		outreg2 using "tables/educSelection.tex",  ///
				drop(_I* o.*) dec(3) adec(3) ///
				addstat("subj", `subj', "Mean all", `meanAll', "SE mean all", `seMeanAll', "Mean participants", `meanSel', "SE mean participants", `seMeanSel') ///
				tex(frag) 
		xi: reg iqRankI  [aw = weight] if explicit == 0, cl(id)
			local meanAll = _b[_cons]
			local seMeanAll = _se[_cons]
		xi: reg iqRankI  [aw = weight] if explicit == 0, cl(id)
			local meanSel = _b[_cons]
			local seMeanSel = _se[_cons]
		xi: reg iqRankI 		inc_bet inc_noBet bet tIq 	`controls' [aw = weight] if iqInc == 1 & explicit == 0, cl(id)
		local subj = e(N_clust)
		outreg2 using "tables/educSelection.tex",  ///
				drop(_I* o.*) dec(3) adec(3) ///
				addstat("subj", `subj', "Mean all", `meanAll', "SE mean all", `seMeanAll', "Mean participants", `meanSel', "SE mean participants", `seMeanSel') ///
				tex(frag) 

	}
	
	// Panel B: Posteriors 
	if 1 {

		cap drop var
		cap gen var = .
		cap gen var_bet = .
		cap gen var_noBet = .
		
		local controls = "i.order i.session "
		
		replace var = abimathRank
		replace var_bet = var * bet
		replace var_noBet = var * (1-bet)
		xi: reg state var_bet var_noBet bet  	 		`controls' [aw = weight] if explicit == 0, cl(id)
		local subj = e(N_clust)
		outreg2 using "tables/educPost.tex",  ///
				drop(_I* o.*) dec(3) addstat("subj", `subj') ///
				tex(frag) replace
				
		replace var = matheLK
		replace var_bet = var * bet
		replace var_noBet = var * (1-bet)
		xi: reg state var_bet var_noBet bet  	 		`controls' [aw = weight] if explicit == 0, cl(id)
		local subj = e(N_clust)
		outreg2 using "tables/educPost.tex",  ///
				drop(_I* o.*) dec(3) addstat("subj", `subj') ///
				tex(frag) 
				
		replace var = STEM
		replace var_bet = var * bet
		replace var_noBet = var * (1-bet)
		xi: reg state var_bet var_noBet bet  	 		`controls' [aw = weight] if explicit == 0, cl(id)
		local subj = e(N_clust)
		outreg2 using "tables/educPost.tex",  ///
				drop(_I* o.*) dec(3) addstat("subj", `subj') ///
				tex(frag) 
				
		replace var = abideutschRank
		replace var_bet = var * bet
		replace var_noBet = var * (1-bet)
		xi: reg state var_bet var_noBet bet  	 		`controls' [aw = weight] if explicit == 0, cl(id)
		local subj = e(N_clust)
		outreg2 using "tables/educPost.tex",  ///
				drop(_I* o.*) dec(3) addstat("subj", `subj') ///
				tex(frag) 
				
		replace var = deutschLK
		replace var_bet = var * bet
		replace var_noBet = var * (1-bet)
		xi: reg state var_bet var_noBet bet  	 		`controls' [aw = weight] if explicit == 0, cl(id)
		local subj = e(N_clust)
		outreg2 using "tables/educPost.tex",  ///
				drop(_I* o.*) dec(3) addstat("subj", `subj') ///
				tex(frag) 
				
		local controls = "`controls' tIq"
		
		replace var = iqRankU
		replace var_bet = var * bet
		replace var_noBet = var * (1-bet)
		xi: reg state var_bet var_noBet bet  	 		`controls' [aw = weight] if explicit == 0 & iqInc == 0, cl(id)
		local subj = e(N_clust)
		outreg2 using "tables/educPost.tex",  ///
				drop(_I* o.*) dec(3) addstat("subj", `subj') ///
				tex(frag) 
				
		replace var = iqRankI
		replace var_bet = var * bet
		replace var_noBet = var * (1-bet)
		xi: reg state var_bet var_noBet bet  	 		`controls' [aw = weight] if explicit == 0 & iqInc == 1, cl(id)
		local subj = e(N_clust)
		outreg2 using "tables/educPost.tex",  ///
				drop(_I* o.*) dec(3) addstat("subj", `subj') ///
				tex(frag) 
	
	
	}
	
}

// APPENDIX TABLE C.6 PRINTED IN STATA OUTPUT WINDOW 
if 1 {
	
	bysort id: egen neverBetTr_i = max(bet) if cost > 0 
		replace neverBetTr_i = 1 - neverBetTr_i
	bysort id: egen alwaysBetTr_i = min(bet) if cost > 0 
	bysort id: egen neverBetCont_i = max(bet) if cost == 0 
		replace neverBetCont_i = 1 - neverBetCont_i
	bysort id: egen alwaysBetCont_i = min(bet) if cost == 0 

	by id: egen neverBetTr 		= mean(neverBetTr_i)
	by id: egen alwaysBetTr 	= mean(alwaysBetTr_i)
	by id: egen neverBetCont 	= mean(neverBetCont_i)
	by id: egen alwaysBetCont 	= mean(alwaysBetCont_i)

	su neverBetTr neverBetCont neverBetCont alwaysBetCont if tag == 1

	
	noisily: di "APPENDIX TABLE C.6"
	
	noisily: di "Column 1"
	noisily: count if tag == 1
	noisily: count if tag == 1
	
	noisily: di "Column 2"
	noisily: count if explicit == 1
	noisily: count if explicit == 0

	noisily: di "Column 3"
	noisily: su bet if explicit == 1
	noisily: su bet if explicit == 0
	
	noisily: di "Column 4"
	noisily: count if  alwaysBetTr 	== 1 & tag == 1
	noisily: count if  alwaysBetCont == 1 & tag == 1

	noisily: di "Column 5"
	noisily: count if neverBetTr 	== 1 & tag == 1
	noisily: count if neverBetCont 	== 1 & tag == 1

}

// APPENDIX TABLE C.7 PRINTED IN STATA OUTPUT WINDOW 
if 1 {	
	noisily: di "APPENDIX TABLE C.7"
	noisily: pwcorr ceRank wtaRankMean iqRankU iqRankI matheLK abimathRank STEM deutschLK abideutschRank if tag == 1, sig
}

// APPENDIX TABLE C.8 
if 1 {
	
		cap gen flexInfo 			= 1 - explicit
		cap gen inc_flexInfo 		= incentive * flexInfo
		cap gen cost_flexInfo 		= cost * flexInfo
		cap gen cost_inc_flexInfo 	= cost * incentive * flexInfo
		
		cap gen ceRank_cost			= ceRank * cost
		cap gen ceRank_inc_cost		= ceRank * cost * incentive
		cap gen ceRank_inc 			= incentive * ceRank
		
		
		reg thresCost inc_bet inc_noBet bet i.session i.order ceRank inc_ceRank [aw = weight], cl(id)
		reg thresCost inc_bet inc_noBet bet i.session i.order ceRank inc_ceRank [aw = weight] if bet == 1, cl(id)

		

		// Col 1 
		if 1 {
		local condition = "explicit == 0"
		reg thresCost ceRank inc_ceRank [aw = weight] if `condition'
			local depVarMean = _b[_cons]
			local depVarSe = _se[_cons]
		reg thresCost inc_bet inc_noBet bet i.session i.order ceRank inc_ceRank [aw = weight] ///
			if `condition' & incentive < 0.51, cl(id)
			local b1 = _b[inc_bet]
			local se1 = _se[inc_bet]
			test inc_bet == 0
			local p = r(p)
			local sig1 = "-"
			if `p' < 0.1 {
				local sig1 = "*"
			}
			if `p' < 0.05 {
				local sig1 = "**"
			}
			if `p' < 0.001 {
				local sig1 = "***"
			}
		reg thresCost inc_bet inc_noBet bet i.session i.order ceRank inc_ceRank [aw = weight] ///
			if `condition' & incentive > 0.49, cl(id)
			local b2 = _b[inc_bet]
			local se2 = _se[inc_bet]
			test inc_bet == 0
			local p = r(p)
			local sig2 = "-"
			if `p' < 0.1 {
				local sig2 = "*"
			}
			if `p' < 0.05 {
				local sig2 = "**"
			}
			if `p' < 0.001 {
				local sig2 = "***"
			}
		reg thresCost inc_bet inc_noBet bet i.session i.order ceRank inc_ceRank [aw = weight] ///
			if `condition' & cost <= 2, cl(id)
			local b3 = _b[inc_bet]
			local se3 = _se[inc_bet]
			test inc_bet == 0
			local p = r(p)
			local sig3 = "-"
			if `p' < 0.1 {
				local sig3 = "*"
			}
			if `p' < 0.05 {
				local sig3 = "**"
			}
			if `p' < 0.001 {
				local sig3 = "***"
			}
		reg thresCost inc_bet inc_noBet bet i.session i.order ceRank inc_ceRank [aw = weight] ///
			if `condition' & cost >= 2, cl(id)
			local b4 = _b[inc_bet]
			local se4 = _se[inc_bet]
			test inc_bet == 0
			local p = r(p)
			local sig4 = "-"
			if `p' < 0.1 {
				local sig4 = "*"
			}
			if `p' < 0.05 {
				local sig4 = "**"
			}
			if `p' < 0.001 {
				local sig4 = "***"
			}
		
		reg thresCost inc_bet inc_noBet noBet i.session i.order ceRank inc_ceRank [aw = weight] ///
			if `condition', cl(id)
			local numSubj = e(N_clust)
			outreg2 using "tables/tableCombinedRisk.tex",  ///
			keep(ceRank inc_ceRank inc_bet inc_noBet noBet) dec(3)  ///
			adec(3) ///
			addstat("#Subj", `numSubj', "b1", `b1', "se1", `se1', "b2", `b2', "se2", `se2', "b3", `b3', "se3", `se3', "b4", `b4', "se4", `se4', "DepVar mean", `depVarMean', "DepVar SE", `depVarSe') /// 
			addtext("Obs included", "All", "sig1", `sig1', "sig2", `sig2', "sig3", `sig3', "sig4", `sig4') ///
			tex(frag) replace 
		}
		
		// Col 2 
		if 1 {
		local condition = "explicit == 0"
		local controls = " "
		reg wtaRankMean ceRank inc_ceRank [aw = weight] if `condition'
			local depVarMean = _b[_cons]
			local depVarSe = _se[_cons]
		reg wtaRankMean inc_bet inc_noBet bet i.session i.order ceRank inc_ceRank [aw = weight] ///
			if `condition' & incentive < 0.51, cl(id)
			local b1 = _b[inc_bet]
			local se1 = _se[inc_bet]
			test inc_bet == 0
			local p = r(p)
			local sig1 = "-"
			if `p' < 0.1 {
				local sig1 = "*"
			}
			if `p' < 0.05 {
				local sig1 = "**"
			}
			if `p' < 0.001 {
				local sig1 = "***"
			}
		reg wtaRankMean inc_bet inc_noBet bet i.session i.order ceRank inc_ceRank [aw = weight] ///
			if `condition' & incentive > 0.49, cl(id)
			local b2 = _b[inc_bet]
			local se2 = _se[inc_bet]
			test inc_bet == 0
			local p = r(p)
			local sig2 = "-"
			if `p' < 0.1 {
				local sig2 = "*"
			}
			if `p' < 0.05 {
				local sig2 = "**"
			}
			if `p' < 0.001 {
				local sig2 = "***"
			}
		reg wtaRankMean inc_bet inc_noBet bet i.session i.order ceRank inc_ceRank [aw = weight] ///
			if `condition' & cost <= 2, cl(id)
			local b3 = _b[inc_bet]
			local se3 = _se[inc_bet]
			test inc_bet == 0
			local p = r(p)
			local sig3 = "-"
			if `p' < 0.1 {
				local sig3 = "*"
			}
			if `p' < 0.05 {
				local sig3 = "**"
			}
			if `p' < 0.001 {
				local sig3 = "***"
			}
		reg wtaRankMean inc_bet inc_noBet bet i.session i.order ceRank inc_ceRank [aw = weight] ///
			if `condition' & cost >= 2, cl(id)
			local b4 = _b[inc_bet]
			local se4 = _se[inc_bet]
			test inc_bet == 0
			local p = r(p)
			local sig4 = "-"
			if `p' < 0.1 {
				local sig4 = "*"
			}
			if `p' < 0.05 {
				local sig4 = "**"
			}
			if `p' < 0.001 {
				local sig4 = "***"
			}
		reg wtaRankMean inc_bet inc_noBet noBet `controls' i.session i.order ceRank inc_ceRank [aw = weight] ///
			if `condition', cl(id)
			local numSubj = e(N_clust)
			outreg2 using "tables/tableCombinedRisk.tex",  ///
			keep(ceRank inc_ceRank inc_bet inc_noBet noBet) dec(3)  ///
			adec(3) ///
			addstat("#Subj", `numSubj', "b1", `b1', "se1", `se1', "b2", `b2', "se2", `se2', "b3", `b3', "se3", `se3', "b4", `b4', "se4", `se4', "DepVar mean", `depVarMean', "DepVar SE", `depVarSe') /// 
			addtext("Obs included", "All", "sig1", `sig1', "sig2", `sig2', "sig3", `sig3', "sig4", `sig4') ///
			tex(frag)  

		}
			
		// Col 3 
		if 1 {
		local condition = "explicit == 1"
		local controls = " "
		reg wtaRankMean ceRank inc_ceRank [aw = weight] if `condition'
			local depVarMean = _b[_cons]
			local depVarSe = _se[_cons]
		reg wtaRankMean inc_bet inc_noBet bet i.session i.order ceRank inc_ceRank [aw = weight] ///
			if `condition' & incentive < 0.51, cl(id)
			local b1 = _b[inc_bet]
			local se1 = _se[inc_bet]
			test inc_bet == 0
			local p = r(p)
			local sig1 = "-"
			if `p' < 0.1 {
				local sig1 = "*"
			}
			if `p' < 0.05 {
				local sig1 = "**"
			}
			if `p' < 0.001 {
				local sig1 = "***"
			}
		reg wtaRankMean inc_bet inc_noBet bet i.session i.order ceRank inc_ceRank [aw = weight] ///
			if `condition' & incentive > 0.49, cl(id)
			local b2 = _b[inc_bet]
			local se2 = _se[inc_bet]
			test inc_bet == 0
			local p = r(p)
			local sig2 = "-"
			if `p' < 0.1 {
				local sig2 = "*"
			}
			if `p' < 0.05 {
				local sig2 = "**"
			}
			if `p' < 0.001 {
				local sig2 = "***"
			}
			local b3 = 0
			local se3 = 0
			local sig3 = "-"
			local b4 = 0
			local se4 = 0
			local sig4 = "-"
			
		reg wtaRankMean inc_bet inc_noBet noBet `controls' i.session i.order ceRank inc_ceRank [aw = weight] ///
			if `condition', cl(id)
			local numSubj = e(N_clust)
			outreg2 using "tables/tableCombinedRisk.tex",  ///
			keep(ceRank inc_ceRank inc_bet inc_noBet noBet) dec(3)  ///
			adec(3) ///
			addstat("#Subj", `numSubj', "b1", `b1', "se1", `se1', "b2", `b2', "se2", `se2', "b3", `b3', "se3", `se3', "b4", `b4', "se4", `se4', "DepVar mean", `depVarMean', "DepVar SE", `depVarSe') /// 
			addtext("Obs included", "All", "sig1", `sig1', "sig2", `sig2', "sig3", `sig3', "sig4", `sig4') ///
			tex(frag)
			
			// Test for difference in selection effect fixed info vs. endogenous info
			if 1 {
				cap gen incExplicit = incentive * explicit
				local condition = "1"
				reg wtaRankMean incentive incExplicit i.cost  i.session i.order ceRank inc_ceRank [aw = weight] ///
					if `condition' & bet == 1, cl(id)
				reg wtaRankMean incentive incExplicit i.cost ceRank inc_ceRank [aw = weight] ///
					if `condition' & bet == 1, cl(id)
					
				local condition = "incentive < 0.51"
				xi: reg wtaRankMean incentive incExplicit i.cost i.session i.order ceRank inc_ceRank [aw = weight] ///
					if `condition' & bet == 1, cl(id)
				local condition = "incentive > 0.49"
				xi: reg wtaRankMean incentive incExplicit i.cost i.session i.order ceRank inc_ceRank [aw = weight] ///
					if `condition' & bet == 1, cl(id)
				local condition = "cost <= 2"
				xi: reg wtaRankMean incentive incExplicit i.cost i.session i.order ceRank inc_ceRank [aw = weight] ///
					if `condition' & bet == 1, cl(id)
				local condition = "cost >= 2 | cost == 0"
				xi: reg wtaRankMean incentive incExplicit i.cost i.session i.order ceRank inc_ceRank [aw = weight] ///
					if `condition' & bet == 1, cl(id)
					
					
					
				// Say that the session and round fixed effects suck up power, so the difference is not statistically significant. 
			}
		}
		
		// Col 4 
		if 1 {
		local condition = "explicit == 0"
		reg wtaRankMean ceRank inc_ceRank [aw = weight] if `condition'
			local depVarMean = _b[_cons]
			local depVarSe = _se[_cons]
		reg wtaRankMean inc_bet cost_bet costInc_bet bet inc_noBet cost_noBet costInc_noBet i.session i.order ceRank inc_ceRank [aw = weight] ///
			if `condition' & incentive < 0.51, cl(id)
			local b1 = _b[costInc_bet]
			local se1 = _se[costInc_bet]
			test costInc_bet == 0
			local p = r(p)
			local sig1 = "-"
			if `p' < 0.1 {
				local sig1 = "*"
			}
			if `p' < 0.05 {
				local sig1 = "**"
			}
			if `p' < 0.001 {
				local sig1 = "***"
			}
		reg wtaRankMean inc_bet cost_bet costInc_bet bet inc_noBet cost_noBet costInc_noBet i.session i.order ceRank inc_ceRank [aw = weight] ///
			if `condition' & incentive > 0.49, cl(id)
			local b2 = _b[costInc_bet]
			local se2 = _se[costInc_bet]
			test costInc_bet == 0
			local p = r(p)
			local sig2 = "-"
			if `p' < 0.1 {
				local sig2 = "*"
			}
			if `p' < 0.05 {
				local sig2 = "**"
			}
			if `p' < 0.001 {
				local sig2 = "***"
			}
		reg wtaRankMean inc_bet cost_bet costInc_bet bet inc_noBet cost_noBet costInc_noBet i.session i.order ceRank inc_ceRank [aw = weight] ///
			if `condition' & cost <= 2, cl(id)
			local b3 = _b[costInc_bet]
			local se3 = _se[costInc_bet]
			test costInc_bet == 0
			local p = r(p)
			local sig3 = "-"
			if `p' < 0.1 {
				local sig3 = "*"
			}
			if `p' < 0.05 {
				local sig3 = "**"
			}
			if `p' < 0.001 {
				local sig3 = "***"
			}
		reg wtaRankMean inc_bet cost_bet costInc_bet bet inc_noBet cost_noBet costInc_noBet i.session i.order ceRank inc_ceRank [aw = weight] ///
			if `condition' & cost >= 2, cl(id)
			local b4 = _b[costInc_bet]
			local se4 = _se[costInc_bet]
			test costInc_bet == 0
			local p = r(p)
			local sig4 = "-"
			if `p' < 0.1 {
				local sig4 = "*"
			}
			if `p' < 0.05 {
				local sig4 = "**"
			}
			if `p' < 0.001 {
				local sig4 = "***"
			}

		reg wtaRankMean inc_bet cost_bet costInc_bet noBet inc_noBet cost_noBet costInc_noBet  i.session i.order ceRank inc_ceRank [aw = weight] ///
			if `condition', cl(id)
			local numSubj = e(N_clust)
			outreg2 using "tables/tableCombinedRisk.tex",  ///
			keep(ceRank inc_ceRank inc_bet cost_bet costInc_bet noBet inc_noBet cost_noBet costInc_noBet) dec(3)  ///
			adec(3) ///
			addstat("#Subj", `numSubj', "b1", `b1', "se1", `se1', "b2", `b2', "se2", `se2', "b3", `b3', "se3", `se3', "b4", `b4', "se4", `se4', "DepVar mean", `depVarMean', "DepVar SE", `depVarSe') /// 
			addtext("Obs included", "All", "sig1", `sig1', "sig2", `sig2', "sig3", `sig3', "sig4", `sig4') ///
			tex(frag)
		}	
		

		// Col 5 
		if 1 {
		local condition = "explicit == 0"
		reg bet ceRank inc_ceRank [aw = weight] if `condition'
			local depVarMean = _b[_cons]
			local depVarSe = _se[_cons]
		reg bet incentive thresCost inc_thresCost i.session i.order ceRank inc_ceRank [aw = weight] ///
			if `condition' & incentive < 0.51, cl(id)
			local b1 = _b[inc_thresCost]
			local se1 = _se[inc_thresCost]
			test inc_thresCost == 0
			local p = r(p)
			local sig1 = "-"
			if `p' < 0.1 {
				local sig1 = "*"
			}
			if `p' < 0.05 {
				local sig1 = "**"
			}
			if `p' < 0.001 {
				local sig1 = "***"
			}
		reg bet incentive thresCost inc_thresCost i.session i.order ceRank inc_ceRank [aw = weight] ///
			if `condition' & incentive > 0.49, cl(id)
			local b2 = _b[inc_thresCost]
			local se2 = _se[inc_thresCost]
			test inc_thresCost == 0
			local p = r(p)
			local sig2 = "-"
			if `p' < 0.1 {
				local sig2 = "*"
			}
			if `p' < 0.05 {
				local sig2 = "**"
			}
			if `p' < 0.001 {
				local sig2 = "***"
			}
		reg bet incentive thresCost inc_thresCost i.session i.order ceRank inc_ceRank [aw = weight] ///
			if `condition' & cost <= 2, cl(id)
			local b3 = _b[inc_thresCost]
			local se3 = _se[inc_thresCost]
			test inc_thresCost == 0
			local p = r(p)
			local sig3 = "-"
			if `p' < 0.1 {
				local sig3 = "*"
			}
			if `p' < 0.05 {
				local sig3 = "**"
			}
			if `p' < 0.001 {
				local sig3 = "***"
			}
		reg bet incentive thresCost inc_thresCost i.session i.order ceRank inc_ceRank [aw = weight] ///
			if `condition' & cost >= 2, cl(id)
			local b4 = _b[inc_thresCost]
			local se4 = _se[inc_thresCost]
			test inc_thresCost == 0
			local p = r(p)
			local sig4 = "-"
			if `p' < 0.1 {
				local sig4 = "*"
			}
			if `p' < 0.05 {
				local sig4 = "**"
			}
			if `p' < 0.001 {
				local sig4 = "***"
			}
		reg bet incentive thresCost inc_thresCost i.session i.order ceRank inc_ceRank [aw = weight] ///
			if `condition' , cl(id)
			local numSubj = e(N_clust)
			outreg2 using "tables/tableCombinedRisk.tex",  ///
			keep(ceRank inc_ceRank incentive thresCost inc_thresCost ) dec(3)  ///
			adec(3) ///
			addstat("#Subj", `numSubj', "b1", `b1', "se1", `se1', "b2", `b2', "se2", `se2', "b3", `b3', "se3", `se3', "b4", `b4', "se4", `se4', "DepVar mean", `depVarMean', "DepVar SE", `depVarSe') /// 
			addtext("Obs included", "All", "sig1", `sig1', "sig2", `sig2', "sig3", `sig3', "sig4", `sig4') ///
			tex(frag)
		}	
		
		// Col 6 
		if 1 {
		local condition = "explicit == 0"				
		local control = " " 
		reg bet ceRank inc_ceRank [aw = weight] if `condition'
			local depVarMean = _b[_cons]
			local depVarSe = _se[_cons]
		reg bet  incentive binResPrice inc_binResPrice i.session i.order ceRank inc_ceRank [aw = weight] ///
			if `condition' & incentive < 0.51, cl(id)
			local b1 = _b[inc_binResPrice]
			local se1 = _se[inc_binResPrice]
			test inc_binResPrice == 0
			local p = r(p)
			local sig1 = "-"
			if `p' < 0.1 {
				local sig1 = "*"
			}
			if `p' < 0.05 {
				local sig1 = "**"
			}
			if `p' < 0.001 {
				local sig1 = "***"
			}
		reg bet  incentive binResPrice inc_binResPrice i.session i.order ceRank inc_ceRank [aw = weight] ///
			if `condition' & incentive > 0.49, cl(id)
			local b2 = _b[inc_binResPrice]
			local se2 = _se[inc_binResPrice]
			test inc_binResPrice == 0
			local p = r(p)
			local sig2 = "-"
			if `p' < 0.1 {
				local sig2 = "*"
			}
			if `p' < 0.05 {
				local sig2 = "**"
			}
			if `p' < 0.001 {
				local sig2 = "***"
			}
		reg bet  incentive binResPrice inc_binResPrice i.session i.order ceRank inc_ceRank [aw = weight] ///
			if `condition' & cost <= 2, cl(id)
			local b3 = _b[inc_binResPrice]
			local se3 = _se[inc_binResPrice]
			test inc_binResPrice == 0
			local p = r(p)
			local sig3 = "-"
			if `p' < 0.1 {
				local sig3 = "*"
			}
			if `p' < 0.05 {
				local sig3 = "**"
			}
			if `p' < 0.001 {
				local sig3 = "***"
			}
		reg bet incentive binResPrice inc_binResPrice i.session i.order ceRank inc_ceRank [aw = weight] ///
			if `condition' & cost >= 2, cl(id)
			local b4 = _b[inc_binResPrice]
			local se4 = _se[inc_binResPrice]
			test inc_binResPrice == 0
			local p = r(p)
			local sig4 = "-"
			if `p' < 0.1 {
				local sig4 = "*"
			}
			if `p' < 0.05 {
				local sig4 = "**"
			}
			if `p' < 0.001 {
				local sig4 = "***"
			}
		xi: reg bet  incentive binResPrice inc_binResPrice `control' i.session i.order ///
			ceRank inc_ceRank [aw = weight]	///
			if `condition' ///
			, cl(id)
			local numSubj = e(N_clust)
			outreg2 using "tables/tableCombinedRisk.tex",  ///
			keep(ceRank inc_ceRank incentive binResPrice inc_binResPrice ) dec(3)  ///
			adec(3) ///
			addstat("#Subj", `numSubj', "b1", `b1', "se1", `se1', "b2", `b2', "se2", `se2', "b3", `b3', "se3", `se3', "b4", `b4', "se4", `se4', "DepVar mean", `depVarMean', "DepVar SE", `depVarSe') /// 
			addtext("Obs included", "All", "sig1", `sig1', "sig2", `sig2', "sig3", `sig3', "sig4", `sig4') ///
			tex(frag)
		}
		
		// Col 7 
		if 1 {
		local condition = "explicit == 1"				
		local control = " " 
		reg bet ceRank inc_ceRank [aw = weight] if `condition'
			local depVarMean = _b[_cons]
			local depVarSe = _se[_cons]
		reg bet ceRank inc_ceRank [aw = weight] if `condition'
			local depVarMean = _b[_cons]
			local depVarSe = _se[_cons]
		reg bet  incentive binResPrice inc_binResPrice i.session i.order ceRank inc_ceRank [aw = weight] ///
			if `condition' & incentive < 0.51, cl(id)
			local b1 = _b[inc_binResPrice]
			local se1 = _se[inc_binResPrice]
			test inc_binResPrice == 0
			local p = r(p)
			local sig1 = "-"
			if `p' < 0.1 {
				local sig1 = "*"
			}
			if `p' < 0.05 {
				local sig1 = "**"
			}
			if `p' < 0.001 {
				local sig1 = "***"
			}
		reg bet  incentive binResPrice inc_binResPrice i.session i.order ceRank inc_ceRank [aw = weight] ///
			if `condition' & incentive > 0.49, cl(id)
			local b2 = _b[inc_binResPrice]
			local se2 = _se[inc_binResPrice]
			test inc_binResPrice == 0
			local p = r(p)
			local sig2 = "-"
			if `p' < 0.1 {
				local sig2 = "*"
			}
			if `p' < 0.05 {
				local sig2 = "**"
			}
			if `p' < 0.001 {
				local sig2 = "***"
			}
			local b3 = 0
			local se3 = 0
			local sig3 = "-"
			local b4 = 0
			local se4 = 0
			local sig4 = "-"
		xi: reg bet  incentive binResPrice inc_binResPrice `control' i.session i.order ///
			ceRank inc_ceRank [aw = weight]	///
			if `condition'  ///
			, cl(id)
			local numSubj = e(N_clust)
			outreg2 using "tables/tableCombinedRisk.tex",  ///
			keep(ceRank inc_ceRank incentive binResPrice inc_binResPrice ) dec(3)  ///
			adec(3) ///
			addstat("#Subj", `numSubj', "b1", `b1', "se1", `se1', "b2", `b2', "se2", `se2', "b3", `b3', "se3", `se3', "b4", `b4', "se4", `se4', "DepVar mean", `depVarMean', "DepVar SE", `depVarSe') /// 
			addtext("Obs included", "All", "sig1", `sig1', "sig2", `sig2', "sig3", `sig3', "sig4", `sig4') ///
			tex(frag)
			
			// Test for difference in selection effect fixed info vs. endogenous info
			if 1 {
				cap gen incExplicit = incentive * explicit
				cap gen binResPriceExplicit = binResPrice * explicit
				cap gen incBinResPriceExplicit = inc_binResPrice * explicit
				local condition = "1"
				local controls = " "
				xi: reg bet  incentive binResPrice inc_binResPrice ///
					explicit incExplicit binResPriceExplicit incBinResPriceExplicit ///
					`control' i.session i.order ///
					ceRank inc_ceRank [aw = weight]	///
					if `condition' ///
					, cl(id)
					test incBinResPriceExplicit = inc_binResPrice
			}
		}
			
		// Col 8 
		if 1 {
		local condition = "explicit == 0"				
		local control = "thresCost cost_incentive"	
		reg bet ceRank inc_ceRank [aw = weight] if `condition'
			local depVarMean = _b[_cons]
			local depVarSe = _se[_cons]
		reg bet incentive binResPrice inc_binResPrice cost_resPrice cost_inc_resPrice i.session i.order ceRank inc_ceRank [aw = weight] ///
			if `condition' & incentive < 0.51, cl(id)
			local b1 = _b[cost_inc_resPrice]
			local se1 = _se[cost_inc_resPrice]
			test cost_inc_resPrice == 0
			local p = r(p)
			local sig1 = "-"
			if `p' < 0.1 {
				local sig1 = "*"
			}
			if `p' < 0.05 {
				local sig1 = "**"
			}
			if `p' < 0.001 {
				local sig1 = "***"
			}
		reg bet incentive binResPrice inc_binResPrice cost_resPrice cost_inc_resPrice i.session i.order ceRank inc_ceRank [aw = weight] ///
			if `condition' & incentive > 0.49, cl(id)
			local b2 = _b[cost_inc_resPrice]
			local se2 = _se[cost_inc_resPrice]
			test cost_inc_resPrice == 0
			local p = r(p)
			local sig2 = "-"
			if `p' < 0.1 {
				local sig2 = "*"
			}
			if `p' < 0.05 {
				local sig2 = "**"
			}
			if `p' < 0.001 {
				local sig2 = "***"
			}
		reg bet incentive binResPrice inc_binResPrice cost_resPrice cost_inc_resPrice i.session i.order ceRank inc_ceRank [aw = weight] ///
			if `condition' & cost <= 2, cl(id)
			local b3 = _b[cost_inc_resPrice]
			local se3 = _se[cost_inc_resPrice]
			test cost_inc_resPrice == 0
			local p = r(p)
			local sig3 = "-"
			if `p' < 0.1 {
				local sig3 = "*"
			}
			if `p' < 0.05 {
				local sig3 = "**"
			}
			if `p' < 0.001 {
				local sig3 = "***"
			}
		reg bet incentive binResPrice inc_binResPrice cost_resPrice cost_inc_resPrice i.session i.order ceRank inc_ceRank [aw = weight] ///
			if `condition' & cost >= 2, cl(id)
			local b4 = _b[cost_inc_resPrice]
			local se4 = _se[cost_inc_resPrice]
			test cost_inc_resPrice == 0
			local p = r(p)
			local sig4 = "-"
			if `p' < 0.1 {
				local sig4 = "*"
			}
			if `p' < 0.05 {
				local sig4 = "**"
			}
			if `p' < 0.001 {
				local sig4 = "***"
			}
		xi: reg bet incentive binResPrice inc_binResPrice cost_resPrice cost_inc_resPrice `control' i.session i.order ///
			ceRank inc_ceRank [aw = weight]	///
			if `condition' ///
			, cl(id)
		local numSubj = e(N_clust)
		outreg2 using "tables/tableCombinedRisk.tex",  ///
			keep(ceRank inc_ceRank incentive binResPrice inc_binResPrice cost_resPrice cost_inc_resPrice) dec(3)  ///
			adec(3) ///
			addstat("#Subj", `numSubj', "b1", `b1', "se1", `se1', "b2", `b2', "se2", `se2', "b3", `b3', "se3", `se3', "b4", `b4', "se4", `se4', "DepVar mean", `depVarMean', "DepVar SE", `depVarSe') /// 
			addtext("Obs included", "All", "sig1", `sig1', "sig2", `sig2', "sig3", `sig3', "sig4", `sig4') ///
			tex(frag)
		}	

}

// SUPPLEMENTARY STATISTICS
if 1 {

	count if tag == 1
	su duration, d

	su bet if state == 1 & explicit == 0
	su bet if state == 0 & explicit == 0
	
	su tpicQualtrics if explicit == 0, d
	su minTpic if explicit == 0, d

	// Sessions table in appendix
	
	tab session if tag == 1
	
	// Decisions changed after belief elicitation
	
	su changedecision
	xi, noomit: reg changedecision i.round, nocons cl(id)
	bysort id: egen everChange = max(changedecision)
	su everChange
	
	// WTA implementation done well enough
	
	gen wtafraccorrect = wtanumcorrect / numtasks
	// graph bar wtafraccorrect, over(session)
	su wtafraccorrect if session >= 5 & tag == 1
	tab wtafraccorrect if session >= 5 & tag == 1
	
	
	
	// Order effects
	
	gen tPicMin = tpicQualtrics / 60
	su tPicMin if order == 1 & explicit == 0 
	su tPicMin if order == 18 & explicit == 0 
		
	capture drop rightDecision
	gen rightDecision = bet == state	
	reg rightDecision order if explicit == 0, cl(id)

	su rightDecision if explicit == 0 & order == 1
	su rightDecision if explicit == 0 & order == 18
	
	// Risk preferences
	
	forvalues i = 1 / 9 {
		su ceRiskNeut`i'
		local riskNeut = r(mean)
		reg ce`i' if tag == 1
		test _b[_cons] == `riskNeut'
	}
	
	// Payoff
	
	replace finalpayoff = 5 if finalpayoff < 5
	su finalpayoff if tag == 1
	
	// Risk Aversion
	
	tab riskAverse
	
	
	// testing hump-shape of selection in low-cost condition for prop 3
	if 1 {
		capture drop inc2*
		gen inc2 = incentive^2
		gen inc2_costM = inc2 * (cost == 2)
		gen inc2_costH = inc2 * (cost == 3)
		local condition = "cost == 1 & incentive >0 "
		local controls = "i.cost"				
		reg wtaRankMean incentive thresCost inc_thresCost inc2* i.session i.order [aw = weight] ///
			if `condition' & bet == 1  & explicit == 0, cl(id)
			local numSubj = e(N_clust)
			
	}
	
	// Educational demographics
	tab matheLK deutschLK if tag == 1
	tab matheLK deutschLK if STEM == 1 & tag == 1, cell
	tab matheLK deutschLK if STEM == 0 & tag == 1, cell
	tab STEM if tag == 1

}
	

	




